﻿/*global analogue*//*jslint bitwise: true, browser: true, eqeqeq: true, immed: true, newcap: true, nomen: true, onevar: true, plusplus: true, regexp: true, undef: true, white: true, indent: 4*/

analogue.methods = {
    addEvent: analogue.events.add,
    delegateEvent: function (type, listener, tag) {
        return this.addEvent(type, function (event) {
            var target = event.target;
            while (target.nodeType !== 1) {
                target = target.parentNode;
            }
            if (!tag || target.nodeName.toLowerCase() === tag) {
                listener.apply(target, arguments);
            }
        });
    },
    getElementsByAttribute: function (name, value, tag) {
        return analogue.selectors.match(this, (tag ? tag : '') + '[' + name + (value ? '~="' + value + '"' : '') + ']');
    },
    getElementsByClassName: function (value, tag) {
        return analogue.selectors.match(this, (tag ? tag : '') + '.' + value.replace(' ', '.'));
    },
    getElementsBySelector: function (selector) {
        return analogue.selectors.match(this, selector);
    },
    removeEvent: analogue.events.remove,
    triggerEvent: analogue.events.trigger
};